package com.demo.tx.seata.controller;

import com.demo.tx.seata.service.tcc.SeataTccExecuteService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SeataTCCController {

    @Resource
    private SeataTccExecuteService seataTccExecuteService;

    @GetMapping("/tcc/prepare")
    public String prepare(@RequestParam("userId") Long userId, @RequestParam("sleepTime") Long sleepTime) throws InterruptedException {
        seataTccExecuteService.executeRemote(userId, sleepTime);
        return "SUCCESS";
    }
}
